package interfaces;

import entidades.Licencia;
import gestores.GestorLicencia;

import java.net.URL;
import java.util.ResourceBundle;

import net.sf.jasperreports.engine.JRException;
import reporte.reporte;

/*import net.sf.jasperreports.engine.JRException;*/

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;

/**
 * Profile Controller.
 */
public class ImprimirLicenciaController extends AnchorPane implements Initializable {
  
   
    @FXML
    public Button buscar;
    
    @FXML
    public Button imprimir;
    
    @FXML
    public TextField textfield1;
    
    @FXML
    public TextField textfield2;
    
    @FXML
    public TextField textfield3;
    
    @FXML
    public TextField textfield4;
    
    private Main application;
  
    public GestorLicencia gestor;
    
    public Licencia licencia;
    
    public ImprimirLicenciaController imprimirlicenciacontroller;
    
    @FXML
    public void setApp(Main application){
        this.application = application;
        imprimirlicenciacontroller= this;
       
       
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
    	//imprimir.setDisable(true);
    	buscar.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
             application.gotoBusquedaDeLicencia(imprimirlicenciacontroller); 
            }
        });
    	
    	imprimir.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
            	reporte reporte1=new reporte(licencia.titular.nombre,licencia.titular.apellido,""+licencia.idLicencia,""+licencia.titular.fechaNac,licencia.titular.direccion,"ARGENTINA",""+licencia.fechaAlta,licencia.vencimiento+"",licencia.clase.idClase,"M/F");
            	try {
					reporte1.verReporte();
				} catch (JRException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
            }
        });
    }
    
    public void cancelar(ActionEvent event){
    	application.gotoCancelar();
    }
    
}
